﻿#ifndef MACO_H
#define MACO_H

#include <QWidget>
#include <tcpclient.h>
#include <intListener.h>
#include <CommonHelper.h>
#include <QTimer>
#include <QTabWidget>
#include <QTabBar>
#include <QDebug>
#include <QProxyStyle>
#include <QPainter>
#include "qtwh.h"
#include "ui_qtwh.h"
#include <QSerialPortInfo>
#include <QSerialPort>
#include <QMessageBox>
#include <dbHelper.h>
#include <QStandardPaths>
#include <QFileDialog>
//#include <QAxObject>
#include <QShowEvent>
#include "tcts.h"
#include "ui_tcts.h"
#include "QRandomGenerator"
#include <QDesktopWidget>

namespace Ui {
class maco;
}

class maco : public QWidget
{
    Q_OBJECT

public:
    explicit maco(QWidget *parent = nullptr);
    ~maco();

signals:
    void changeMainWindow();

private slots:
    void on_top_bt1_clicked();
    void on_top_bt2_clicked();
    void on_top_bt3_clicked();
    void readyRead_Slot();

    /**
     * 热盖温度读取按钮槽函数,向下位机发送热盖温度读取指令
     *
     * @param 无
     * @return 空
     *
     * @author cnr
     * @date 2024-6-6
     */
    void on_rgwd_bt1_clicked();

    void on_rgwd_bt2_clicked();

    void on_rgwd_bt3_clicked();

    void on_dkg_cb_currentTextChanged(const QString &arg1);

    void on_dqk_bt_clicked();

    void on_dqg_bt_clicked();

    void on_ygtd_cb_activated(const QString &arg1);

    void on_ad1time_bt_clicked();

    void on_adtimes_bt_clicked();

    void on_adyd_bt_clicked();

    void on_spr_bt_clicked();

    void on_spw_bt_clicked();

    void on_spy_bt_clicked();

    void on_spf_bt_clicked();

    void on_sprte_bt_clicked();

    void on_sprst_bt_clicked();

    void on_xzr_bt_clicked();

    void on_xzw_bt_clicked();

    void on_xzy_bt_clicked();

    void on_xzf_bt_clicked();

    void on_xzrte_bt_clicked();

    void on_xzrst_bt_clicked();

    void on_gqt_cb_activated(const QString &arg1);

    void on_gqr_bt_clicked();

    void on_gqw_bt_clicked();

    void on_cmk_bt_clicked();

    void on_cmg_bt_clicked();

    void on_djss_bt_clicked();

    void on_hclx_cb_activated(const QString &arg1);

    void on_djfw_bt_clicked();

    void on_rkrzcs_bt_clicked();

    void on_rktzrz_bt_clicked();

    void on_sjwr_bt_clicked();

    void on_sjww_bt_clicked();

    void on_sw_bt_clicked();

    void on_jw_bt_clicked();

    void on_sjws_bt_clicked();

    void on_jr_bt_clicked();

    void on_zl_bt_clicked();

    void on_jzs_bt_clicked();

    void on_kbr_bt_clicked();

    void on_kbw_bt_clicked();

    void on_bot_bt3_clicked();

    void on_bot_bt4_clicked();

    void on_bot_bt2_clicked();

    void sbo_Slot();
    void sbc_Slot();
    void fso_Slot();
    void fsc_Slot();
    void ckcon_Slot();
    void serialPortRead_Slot();

    /**
     * 恢复初始按钮点击槽函数
     *
     * @param 无
     * @return 空
     *
     * @author cnr
     * @date 2024-6-13
     */
    void on_bot_bt1_clicked();

    void on_return_bt_clicked();

    void on_bot_bt2_2_clicked();

    void pctab();
    void on_A_bt_clicked();

    void on_C_bt_clicked();

    void on_B_bt_clicked();

    void on_D_bt_clicked();

    void on_E_bt_clicked();

    void on_F_bt_clicked();

    void pcread_clicked();
    void on_pc_cb_currentTextChanged(const QString &arg1);

    void pcset_clicked();
    void on_pc_tab_cellChanged(int row, int column);

    void on_bjbc_bt_clicked();
    void on_bjdr_bt_clicked();
    void on_bjdc_bt_clicked();
    void on_bjdqbt_clicked();
    void doorStatusChanged();
    void on_open_bt_clicked();

    void on_gqr_bt_2_clicked();

    void on_gqw_bt_2_clicked();

private:
    void showEvent(QShowEvent *event) override;

private:
    Ui::maco *ui;
    QSerialPort *serialPort;
    void adtw();
    void sptw();
    TcpClient *tcpClient;
    CommonHelper* common;
    qtwh* qtwh1;
    QByteArray buffer;// 网口接收消息
    QString header="6200";
    QString frame_Type = "003B";
    QString frame_Type2 = "003A";
    QString frame_Type3 = "003C";
    QString frame_Type4 = "003D";
    QString frame_Type5 = "003E";
    QString end_frame = "55AA";
    int litfl=1;
    int litopfl=1;
    int litqrfl=1;
    int ads = 0;
    QTimer *timSend5=new QTimer;// AD值请求定时器
    int currentRow,currentColumn;
    int adfl=0;
    int djhang,djlie,djhlie;
    int hctype=1;

    void xztw();
    void sjwtab();
    void kbtw();
    void serialPortSend_Slot(QByteArray data);

    QString pcjzk = "A";
    QString pcjztd = "FAM";
    int flpc=0;
    int pcadfl=0;
    int pcadtime=1;
    QMap<QString,int> pcmap;
    void numsum();
    int rgfl=0,dgfl=0,spdjfl=0,xzdjfl=0,cmfl=0,rkfl=0,sjwfll=0,jjfl=0;
    void bjtab();
    tcts *tcts1;
};
//自定义tabbar的样式
class CustomTabStyle:public QProxyStyle{
public:
    CustomTabStyle(){}
    QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
    void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
};
#endif // MACO_H
